﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Artists.aspx.cs" Inherits="ImgForecast.admin.Artists" %>

<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="cc2" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <cc1:Grid ID="Grid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
        CallbackMode="true" Serialize="true" AllowAddingRecords="true" PageSize="100">
        <ClientSideEvents OnClientCallbackError="true" />
        <Columns>
            <cc1:Column ID="Column1" DataField="ArtistID" Visible="false" ReadOnly="true" HeaderText="Office ID"
                Width="100" runat="server" />
            <cc1:Column ID="Column2" DataField="Lastname" HeaderText="Lastname" Width="100" runat="server" />
            <cc1:Column ID="Column3" DataField="Firstname" HeaderText="Firstname" Width="100"
                runat="server" />
            <cc1:Column ID="Column4" DataField="GroupName" HeaderText="GroupName" Width="100"
                runat="server" />
            <cc1:Column ID="Column5" DataField="GL_Code" HeaderText="GL Code" Width="100" runat="server" />
            <cc1:Column ID="Column6" DataField="IsPerson" HeaderText="IsPerson" Width="100" runat="server">
                <TemplateSettings TemplateId="TemplateIsPerson" EditTemplateId="TemplateEditIsPerson" />
            </cc1:Column>
            <cc1:Column ID="Column7" DataField="ArtistTypeID" HeaderText="Artist Type" Width="200"
                runat="server">
                <TemplateSettings TemplateId="ArtistTypeTemplate" EditTemplateId="ArtistTypeEditTemplate" />
            </cc1:Column>
            <cc1:Column ID="Column8" DataField="ArtistSubTypeID" HeaderText="Artist Sub Type"
                Width="200" runat="server">
                <TemplateSettings TemplateId="ArtistSubTypeTemplate" EditTemplateId="ArtistSubTypeEditTemplate" />
            </cc1:Column>
            <cc1:Column ID="Column9" HeaderText="Edit" AllowEdit="true" AllowDelete="true" Width="125"
                runat="server" />
        </Columns>
        <Templates>
            <cc1:GridTemplate runat="server" ID="ArtistSubTypeEditTemplate" ControlID="ddlArtistSubtype"
                ControlPropertyName="value">
                <Template>
                    <cc2:OboutDropDownList ID="ddlArtistSubtype" runat="server" DataSourceID="SqlDataSource2"
                        DataTextField="Name" DataValueField="ArtistSubTypeID">
                    </cc2:OboutDropDownList>
                </Template>
            </cc1:GridTemplate>
            <cc1:GridTemplate runat="server" ID="ArtistSubTypeTemplate">
                <Template>
                    <%# Container.DataItem["ArtistSubTypeName"]%>
                </Template>
            </cc1:GridTemplate>
            <cc1:GridTemplate runat="server" ID="ArtistTypeEditTemplate" ControlID="ddlArtistType"
                ControlPropertyName="value">
                <Template>
                    <cc2:OboutDropDownList ID="ddlArtistType" runat="server" DataSourceID="SqlDataSource3"
                        DataTextField="Name" DataValueField="ArtistTypeID">
                    </cc2:OboutDropDownList>
                </Template>
            </cc1:GridTemplate>
            <cc1:GridTemplate runat="server" ID="ArtistTypeTemplate">
                <Template>
                    <%# Container.DataItem["ArtistTypeName"]%>
                </Template>
            </cc1:GridTemplate>
            <cc1:GridTemplate runat="server" ID="TemplateIsPerson" UseQuotes="true">
                <Template>
                    <%# (Container.Value == "True" ? "Yes" : "No")  %>
                </Template>
            </cc1:GridTemplate>
            <cc1:GridTemplate runat="server" ID="TemplateEditIsPerson" ControlID="chkIsPerson"
                ControlPropertyName="checked" UseQuotes="false">
                <Template>
                    <input type="checkbox" id="chkIsPerson" />
                </Template>
            </cc1:GridTemplate>
        </Templates>
    </cc1:Grid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
        DeleteCommand="DELETE FROM [Artists] WHERE [ArtistID] = @ArtistID" InsertCommand="INSERT INTO [Artists] ([Firstname], [Lastname], [GL_Code], [IsPerson], [GroupName], [ArtistTypeID], [ArtistSubTypeID]) VALUES (@Firstname, @Lastname, @GL_Code, @IsPerson, @GroupName, @ArtistTypeID, @ArtistSubTypeID)"
        SelectCommand="SELECT     Artists.ArtistID, Artists.Firstname, Artists.Lastname, Artists.GL_Code, Artists.IsPerson, Artists.GroupName, Artists.ArtistTypeID, Artists.ArtistSubTypeID,  ArtistSubType.Name as ArtistSubTypeName, ArtistType.Name AS ArtistTypeName FROM         Artists INNER JOIN ArtistSubType ON Artists.ArtistSubTypeID = ArtistSubType.ArtistSubTypeID INNER JOIN ArtistType ON Artists.ArtistTypeID = ArtistType.ArtistTypeID"
        UpdateCommand="UPDATE [Artists] SET [Firstname] = @Firstname, [Lastname] = @Lastname, [GL_Code] = @GL_Code, [IsPerson] = @IsPerson, [GroupName] = @GroupName, [ArtistTypeID] = @ArtistTypeID, [ArtistSubTypeID] = @ArtistSubTypeID WHERE [ArtistID] = @ArtistID">
        <DeleteParameters>
            <asp:Parameter Name="ArtistID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Firstname" Type="String" />
            <asp:Parameter Name="Lastname" Type="String" />
            <asp:Parameter Name="GL_Code" Type="String" />
            <asp:Parameter Name="IsPerson" Type="Boolean" />
            <asp:Parameter Name="GroupName" Type="String" />
            <asp:Parameter Name="ArtistTypeID" Type="Int32" />
            <asp:Parameter Name="ArtistSubTypeID" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Firstname" Type="String" />
            <asp:Parameter Name="Lastname" Type="String" />
            <asp:Parameter Name="GL_Code" Type="String" />
            <asp:Parameter Name="IsPerson" Type="Boolean" />
            <asp:Parameter Name="GroupName" Type="String" />
            <asp:Parameter Name="ArtistTypeID" Type="Int32" />
            <asp:Parameter Name="ArtistSubTypeID" Type="Int32" />
            <asp:Parameter Name="ArtistID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
        SelectCommand="SELECT [Name], [ArtistSubTypeID] FROM [ArtistSubType] ORDER BY [Name]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
        SelectCommand="SELECT [Name], [ArtistTypeID] FROM [ArtistType] ORDER BY [Name]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
        SelectCommand="SELECT [Name], [ArtistTypeID] FROM [ArtistType] WHERE ([ArtistTypeID] = @ArtistTypeID)">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="ArtistTypeID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
